﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DCRF.Common.Connection;
using DCRF.Common.Interface;

namespace DCRF.BaseBlocks.Commander.Console.Nodes
{
    public class ConnectorsNode: INode
    {
        public TreeNode myNode = null;
        public IBlockWeb myWeb = null;
        public Guid myId = Guid.Empty;

        public ConnectorsNode(TreeNode node, IBlockWeb web, Guid id)
        {
            myNode = node;
            myWeb = web;
            myId = id;
            myNode.Tag = this;

            Refresh();
        }

        public object ProcessRequest(string serviceName, params object[] args)
        {
            if (serviceName == "REF")
            {
                Refresh();
            }
           

            return null;
        }

        public List<string> Commands
        {
            get
            {
                List<string> result = new List<string>();
                result.Add("REF");

                return result;
            }
        }


        public void Refresh()
        {
            myNode.Nodes.Clear();
            myNode.Text = "Connectors";

            //TODO: fix
            //IEnumerable<string> cs = myWeb[myId].ConnectorKeys;

            //foreach (string c in cs)
            //{
            //    TreeNode tn = new TreeNode();
            //    myNode.Nodes.Add(tn);

            //    new ConnectorNode(tn, myWeb, myId, c);
            //}

        }

    }
}
